<template>
  <page-header-wrapper :title="dynamicTitle" @back="() => $router.go(-1)">
    <a-card>
      <div>
        <a-descriptions title="申请详情" bordered>
          <a-descriptions-item label="申请单号:" :span="3">
            <span>{{ centerList.applyNo }}</span>
            <span class="status">{{ centerList.status | filtersState }}</span>
          </a-descriptions-item>
          <a-descriptions-item label="甲办方:"> {{ centerList.sponsorName }}</a-descriptions-item>
          <a-descriptions-item label="项目编号:">
            {{ centerList.ptsNo }}
          </a-descriptions-item>
          <a-descriptions-item label="付款类型:">
            {{ centerList.type == 1 ? '研究者费用' : '受试者费用' }}
          </a-descriptions-item>
          <a-descriptions-item label="收款人员:">
            {{ centerList.userName }}
          </a-descriptions-item>
          <a-descriptions-item label="收款账号:">
            {{ centerList.bankName }} {{ centerList.bankOpenInfo }} {{ centerList.bankCardNo }}
          </a-descriptions-item>
          <a-descriptions-item label="结算币种:">
            {{ centerList.moneyType | NumberFormat }}
          </a-descriptions-item>
          <a-descriptions-item label="申请金额:">
            {{ centerList.totalAmount | formatAmount }}
          </a-descriptions-item>
          <a-descriptions-item label="当前状态:">
            {{ centerList.status | filtersState }}
          </a-descriptions-item>
          <a-descriptions-item label="支付单号:">
            {{ centerList.payNo }}
          </a-descriptions-item>
        </a-descriptions>
      </div>
      <div>
        <a-tabs default-active-key="1" @change="callback">
          <a-tab-pane key="1" tab="费用明细">
            <a-table
              :data-source="centerList.detailList"
              :columns="columns"
              :rowKey="record => record.id"
              :pagination="false"
            >
              <span slot="data" slot-scope="text, record">
                <template>
                  {{ record.happenDate | moment() }}
                </template>
              </span>
              <span slot="amount" slot-scope="text, record">
                <template> ￥{{ record.amount | formatAmount }} </template>
              </span>
              <span slot="address" slot-scope="text, record">
                <template>
                  <a :href="record.fileUrl">查看</a>
                </template>
              </span>
            </a-table>
          </a-tab-pane>
          <a-tab-pane key="2" tab="支付状态" force-render>
            <a-steps direction="vertical" size="small" :current="centerList.status">
              <a-step title="待提交" />
              <a-step title="PI待审核" />
              <a-step title="PI已驳回" />
              <a-step title="PM待审核" />
              <a-step title="PM已驳回" />
              <a-step title="待支付" />
              <a-step title="保税中" />
              <a-step title="已完成" />
            </a-steps>
          </a-tab-pane>
        </a-tabs>
        <div class="btnContent">
          <a-button type="danger" ghost style="margin:5px 0 0 5px">
            驳回
          </a-button>
          <a-button type="primary" style="margin:5px 0 0 5px">
            同意
          </a-button>
        </div>
      </div>
    </a-card>
  </page-header-wrapper>
</template>
<script>
import { payAuditListdetails } from '@/api/pay/pay'
export default {
  props: {},
  components: {},
  data () {
    return {
      centerList: null,
      // tab切换时，更改queryParams中的状态字段。
      dynamicTitle: '付款详情',
      columns: [
        {
          title: 'ID',
          dataIndex: 'id'
        },
        {
          title: '访视阶段',
          dataIndex: 'visitRecordInfo'
        },
        {
          title: '发生日期',
          dataIndex: 'happenDate',
          scopedSlots: { customRender: 'data' }
        },
        {
          title: '报销类目',
          dataIndex: 'applyType'
        },
        {
          title: '报销金额',
          dataIndex: 'amount',
          scopedSlots: { customRender: 'amount' }
        },
        {
          title: '文件',
          dataIndex: 'address',
          scopedSlots: { customRender: 'address' }
        }
      ]
    }
  },
  created () {},
  mounted () {
    this.applicationDetails()
  },
  methods: {
    applicationDetails () {
      const detailId = this.$route.query.id
      // 请求中心列表
      payAuditListdetails({ id: detailId }).then(res => {
        this.centerList = res
      })
    },
    callback (key) {
      console.log(key)
    }
  },
  filters: {
    filtersState (val) {
      if (val === 1) {
        return '待提交'
      } else if (val === 2) {
        return 'PI待审核'
      } else if (val === 3) {
        return 'PI已驳回'
      } else if (val === 4) {
        return 'PM待审核'
      } else if (val === 5) {
        return 'PM已驳回'
      } else if (val === 6) {
        return '待支付'
      } else if (val === 7) {
        return '保税中'
      } else if (val === 8) {
        return '已完成'
      }
    }
  }
}
</script>
<style>
.status {
  margin: 0 20px;
  padding: 3px 10px;
  border: 1px solid #f59a23;
  border-radius: 40px;
  color: #f59a23;
}
.btnContent {
  display: flex;
  justify-content: center;
  padding-top: 15px;
}
</style>
